<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:BrokenHouse.Windows.Parts.Wizard"
                    xmlns:input="clr-namespace:BrokenHouse.Windows.Parts.Wizard.Input"
                    xmlns:windows="clr-namespace:BrokenHouse.Windows"
                    xmlns:controls="clr-namespace:BrokenHouse.Windows.Controls"
                    xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
                    xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
                    xmlns:resources="clr-namespace:BrokenHouse.Resources"
                    xmlns:transitions="clr-namespace:BrokenHouse.Windows.Parts.Transition.Primitives"
                    xmlns:primitives="clr-namespace:BrokenHouse.Windows.Parts.Wizard.Primitives">

    <!-- Classic Wizard Header Background -->
    <SolidColorBrush x:Key="{x:Static local:WizardElements.ClassicWizardHeaderBackgroundKey}"
                     Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}"/>

    <!-- Classic Wizard Page Background -->
    <SolidColorBrush x:Key="{x:Static local:WizardElements.ClassicContentPageBackgroundKey}"
                     Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"/>

    <!-- Classic Wizard Title Page Background -->
    <SolidColorBrush x:Key="{x:Static local:WizardElements.ClassicTitlePageBackgroundKey}"
                     Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}"/>

    <!-- Classic Wizard Page Background -->
    <SolidColorBrush x:Key="{x:Static local:WizardElements.ClassicWizardFooterBackgroundKey}"
                     Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"/>

    <!-- Classic Wizard Page Border -->
    <SolidColorBrush x:Key="{x:Static local:WizardElements.ClassicWizardPageBorderKey}"
                     Color="{DynamicResource {x:Static SystemColors.ControlDarkColorKey}}"/>
    
    <!--- Wizard Control Style -->
    <Style TargetType="{x:Type local:ClassicWizardControl}" x:Key="{x:Static local:WizardElements.ClassicWizardStyleKey}">
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ClassicWizardControl}">
                    <DockPanel x:Name="PART_RootLayout">
                        
                        <!-- Buttons With an etched line above -->
                        <themes:ClassicBorderDecorator x:Name="PART_ButtonPanel" DockPanel.Dock="Bottom" SnapsToDevicePixels="true" 
                                                       Background="{DynamicResource {x:Static local:WizardElements.ClassicWizardFooterBackgroundKey}}"
                                                       BorderStyle="Etched" BorderThickness="0,2,0,0">
                            <StackPanel Orientation="Horizontal" 
                                        HorizontalAlignment="Right" 
                                        Margin="6,6,6,6"
                                        KeyboardNavigation.TabNavigation="Local">
                                <Button x:Name="PART_BackButton" 
                                        Command="input:WizardCommands.Back"
                                        Width="70" Height="23" Margin="4"
                                        Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BackButtonState.Label}"
                                        Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BackButtonState.Visibility}"/>
                                <Button Command="input:WizardCommands.Next"
                                        Width="70" Height="23" Margin="4"
                                        Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NextButtonState.Label}"
                                        IsDefault="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NextButtonState.IsDefault}"
                                        Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NextButtonState.Visibility}"/>
                                <Button Command="input:WizardCommands.Finish"
                                        Width="70" Height="23" Margin="4"
                                        Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FinishButtonState.Label}"
                                        IsDefault="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FinishButtonState.IsDefault}"
                                        Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FinishButtonState.Visibility}"/>
                                <Button Command="input:WizardCommands.Cancel"
                                        Width="70" Height="23" Margin="4"
                                        Content="{x:Static resources:Strings.WizardControl_Cancel}"
                                        IsCancel="True"/>
                            </StackPanel>
                        </themes:ClassicBorderDecorator>


                        <!-- This is the optional error section. If an error occurs we will place
                             the error here. We also may want to animate it. -->
                        <themes:ClassicBorderDecorator x:Name="PART_ErrorPanel" DockPanel.Dock="Bottom" SnapsToDevicePixels="true" 
                                                       Background="{DynamicResource {x:Static local:WizardElements.ClassicWizardFooterBackgroundKey}}"
                                                       BorderStyle="Raised" BorderThickness="1">
                            <StackPanel Orientation="Horizontal">
                                <controls:Icon Source="{x:Static controls:TaskIcons.Error}" Width="16" Height="16" Margin="4" />
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <TextBlock Width="Auto" Height="Auto" TextWrapping="Wrap" Margin="3,3,3,3"
                                               Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=LastError}"/>
                                </StackPanel>
                            </StackPanel>
                        </themes:ClassicBorderDecorator>
                        
                        <!-- The actual content on the wizard control - the currently selected page -->
                        <Border ClipToBounds="True">
                            <transitions:TransitionPresenter x:Name="PART_PageHost" FlowDirection="LeftToRight"
                                                              TransitionEffect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TransitionEffect}"
                                                              VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"/>
                        </Border>
                    </DockPanel>
                    
                    <ControlTemplate.Triggers>

                        <!-- If the message is blank we do not want to show the error message-->
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsLastErrorVisible, Mode=OneWay}" Value="false">
                            <Setter TargetName="PART_ErrorPanel" Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <!-- Wizard Header Style -->
    <Style TargetType="{x:Type primitives:ClassicWizardHeader}" x:Key="{x:Static local:WizardElements.ClassicWizardHeaderStyleKey}">
        <Setter Property="Padding" Value="20,6,3,6"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type primitives:ClassicWizardHeader}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        
                        <!-- The text is to the left -->
                        <StackPanel x:Name="PART_Content" VerticalAlignment="Center" Margin="{TemplateBinding Padding}" >
                            
                            <!-- Show the header -->
                            <TextBlock VerticalAlignment="Center" TextTrimming="WordEllipsis" FontWeight="Bold"
                                       Text="{TemplateBinding Title}"/>

                            <!-- Show the content -->
                            <Grid x:Name="PART_SubHeading" Margin="20,0,0,0" >
                                <StackPanel x:Name="PART_SubHeadingSizer" Visibility="Hidden">
                                    <TextBlock Text="X"/>
                                    <TextBlock Text="X"/>
                                </StackPanel>
                                <TextBlock TextTrimming="WordEllipsis" TextWrapping="Wrap"
                                           MaxHeight="{Binding ElementName=PART_SubHeadingSizer, Path=ActualHeight}"
                                           MinHeight="{Binding ElementName=PART_SubHeadingSizer, Path=ActualHeight}"
                                           Text="{TemplateBinding Description}"/>
                            </Grid>
                        </StackPanel>
                    </Border>
                </ControlTemplate>

            </Setter.Value>
        </Setter>
    </Style>

    <!-- Content Wizard Page Style -->
    <Style TargetType="{x:Type local:ClassicWizardContentPage}" x:Key="{x:Static local:WizardElements.ClassicContentPageStyleKey}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="{DynamicResource {x:Static local:WizardElements.ClassicContentPageBackgroundKey}}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static local:WizardElements.ClassicWizardPageBorderKey}}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ClassicWizardContentPage}">
                    <Border Margin="{TemplateBinding Padding}"
                            Background="{TemplateBinding Background}"
                            BorderThickness="{TemplateBinding BorderThickness}"  
                            BorderBrush="{TemplateBinding BorderBrush}">
                        
                        <DockPanel>
                            <!-- Header -->
                            <Grid x:Name="PART_Header" DockPanel.Dock="Top"  Background="{TemplateBinding BannerBackground}">
                                <primitives:ClassicWizardHeader x:Name="PART_BannerHeader" 
                                                                Margin="{TemplateBinding BannerPadding}"
                                                                Title="{TemplateBinding Title}"
                                                                Description="{TemplateBinding Description}"/>
                                <ContentPresenter x:Name="PART_Banner" RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                  ContentSource="Banner" 
                                                  ContentTemplate="{TemplateBinding BannerTemplate}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalBannerAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalBannerAlignment}"
                                                  MaxHeight="{Binding ElementName=PART_BannerHeader, Path=ActualHeight}"/>
                            </Grid>
                            
                            <!-- Separator -->
                            <themes:ClassicBorderDecorator x:Name="PART_HeaderSeparator" 
                                                           DockPanel.Dock="Top" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                           BorderStyle="None" BorderThickness="0,0,0,2"/>

                            <!-- Page Content -->
                            <ContentPresenter x:Name="PART_Content" RecognizesAccessKey="True" Margin="40,10,40,10"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                              ContentSource="Content" 
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        
                        <!-- If we use wide margins then we tweak the padding -->
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=UseWideMargins}" Value="True">
                            <Setter Property="Margin" TargetName="PART_Content" Value="20,10,20,10"/>
                        </DataTrigger>
                        
                        <!-- If we do not have a banner background then we set it to the default -->
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=BannerBackground}" Value="{x:Null}">
                            <Setter Property="Background" TargetName="PART_Header" Value="{DynamicResource {x:Static local:WizardElements.ClassicWizardHeaderBackgroundKey}}"/>
                        </DataTrigger>

                        <Trigger Property="BannerSeparatorStyle" Value="Etched">
                            <Setter Property="BorderStyle" TargetName="PART_HeaderSeparator" Value="Etched"/>
                        </Trigger>
                        <Trigger Property="BannerSeparatorStyle" Value="Sunken">
                            <Setter Property="BorderStyle" TargetName="PART_HeaderSeparator" Value="Sunken"/>
                        </Trigger>
                        <Trigger Property="BannerSeparatorStyle" Value="Raised">
                            <Setter Property="BorderStyle" TargetName="PART_HeaderSeparator" Value="Raised"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Content Wizard Page Style -->
    <Style TargetType="{x:Type local:ClassicWizardTitlePage}" x:Key="{x:Static local:WizardElements.ClassicTitlePageStyleKey}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="{DynamicResource {x:Static local:WizardElements.ClassicTitlePageBackgroundKey}}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static local:WizardElements.ClassicWizardPageBorderKey}}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ClassicWizardTitlePage}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Margin="{TemplateBinding Padding}">
                        
                        <DockPanel >
                            
                            <!-- Sidebar -->
                            <DockPanel DockPanel.Dock="Left" x:Name="PART_Sidebar" Background="{TemplateBinding WatermarkBackground}">

                                <!-- Separator -->
                                <themes:ClassicBorderDecorator x:Name="PART_SidebarSeparator"
                                                               DockPanel.Dock="Right" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                               BorderStyle="None" BorderThickness="2,0,0,0" />

                                <!-- Display the content -->
                                <ContentPresenter Content="{TemplateBinding Watermark}"
                                                  ContentTemplate="{TemplateBinding WatermarkTemplate}"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                  HorizontalAlignment="{TemplateBinding HorizontalWatermarkAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalWatermarkAlignment}"/>

                            </DockPanel>

                            <!-- Content -->
                            <DockPanel Margin="10">
                                <TextBlock DockPanel.Dock="Top" Margin="0,0,0,30"
                                           Text="{TemplateBinding Title}" FontSize="18" FontWeight="Bold"
                                           TextWrapping="Wrap"/>
                                
                                <ContentPresenter RecognizesAccessKey="True" 
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                  ContentSource="Content" 
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </DockPanel>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WatermarkSeparatorStyle" Value="Etched">
                            <Setter Property="BorderStyle" TargetName="PART_SidebarSeparator" Value="Etched"/>
                        </Trigger>
                        <Trigger Property="WatermarkSeparatorStyle" Value="Sunken">
                            <Setter Property="BorderStyle" TargetName="PART_SidebarSeparator" Value="Sunken"/>
                        </Trigger>
                        <Trigger Property="WatermarkSeparatorStyle" Value="Raised">
                            <Setter Property="BorderStyle" TargetName="PART_SidebarSeparator" Value="Raised"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>
